package server.demo.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import server.demo.entity.User;

import java.time.LocalDateTime;
import java.util.Optional;

@Repository
public interface UserRepository extends JpaRepository<User, Long> {
    Optional<User> findByUsername(String username);
    Optional<User> findByIdCard(String idCard);
    boolean existsByUsername(String username);
    boolean existsByIdCard(String idCard);
    
    // 统计方法
    long countByRole(User.UserRole role);
    long countByCreatedAtBetween(LocalDateTime start, LocalDateTime end);
}